/*    */ package com.zimbra.cs.service.mail;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.MailConstants;
/*    */ import com.zimbra.common.soap.SoapFaultException;
/*    */ import com.zimbra.cs.mailbox.ACL;
/*    */ import com.zimbra.cs.mailbox.Folder;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.cs.mailbox.OperationContext;
/*    */ import com.zimbra.cs.mailbox.acl.FolderACL;
/*    */ import com.zimbra.cs.service.util.ItemId;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetEffectiveFolderPerms
/*    */   extends MailDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException, SoapFaultException
/*    */   {
/* 38 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 39 */     OperationContext octxt = getOperationContext(zsc, context);
/*    */     
/* 41 */     Element eFolder = request.getElement("folder");
/* 42 */     String fid = eFolder.getAttribute("l");
/*    */     
/* 44 */     ItemId iid = new ItemId(fid, zsc);
/* 45 */     int folderId = iid.getId();
/*    */     
/*    */ 
/* 48 */     String ownerAcctId = iid.getAccountId();
/* 49 */     Mailbox mbox; Mailbox mbox; if (ownerAcctId == null) {
/* 50 */       mbox = getRequestedMailbox(zsc);
/*    */     } else {
/* 52 */       mbox = MailboxManager.getInstance().getMailboxByAccountId(ownerAcctId);
/*    */     }
/* 54 */     Folder folder = mbox.getFolderById(null, folderId);
/*    */     
/*    */ 
/* 57 */     Short perms = FolderACL.getEffectivePermissionsLocal(octxt, mbox, folder);
/*    */     
/* 59 */     Element response = zsc.createElement(MailConstants.GET_EFFECTIVE_FOLDER_PERMS_RESPONSE);
/* 60 */     encodePerms(response, perms);
/*    */     
/* 62 */     return response;
/*    */   }
/*    */   
/*    */   private void encodePerms(Element response, Short perms) {
/* 66 */     String permsStr = ACL.rightsToString(perms.shortValue());
/* 67 */     Element eFolder = response.addElement("folder");
/* 68 */     eFolder.addAttribute("perm", permsStr);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/GetEffectiveFolderPerms.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */